/**
 * 
 */
package xiaojian.toolkit.netty.handler.codec.http.transformer;

import io.netty.handler.codec.http.FullHttpRequest;
import xiaojian.toolkit.netty.handler.codec.http.reactor.HttpReactor;


/**
 * @author hp
 *
 */
public class HttpReactorAdapter implements HttpRequestTransformer {

	private	HttpRequestTransformer	impl;
	private HttpReactor reactor;
    private Object defaultRequestObject;
	
	/**
	 * @return the impl
	 */
	public HttpRequestTransformer getImpl() {
		return impl;
	}

	/**
	 * @param impl the impl to set
	 */
	public void setImpl(HttpRequestTransformer impl) {
		this.impl = impl;
	}

	/**
	 * @return the reactor
	 */
	public HttpReactor getReactor() {
		return reactor;
	}

	/**
	 * @param reactor the reactor to set
	 */
	public void setReactor(HttpReactor reactor) {
		this.reactor = reactor;
	}

	@Override
	public Object transform(FullHttpRequest from) {
		if ( null != reactor ) {
			reactor.onHttpRequest(from);
		}
	
		if ( null != impl ) {
			return impl.transform(from);
		}
		else {
			return	defaultRequestObject;
		}
	}

    public void setDefaultRequestObject(Object defaultRequestObject) {
        this.defaultRequestObject = defaultRequestObject;
    }
}
